<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加优惠卷</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/Application/iframe/assets/libs/layuiadmin/layui/css/layui.css"/>
    <link rel="stylesheet" href="/Application/iframe/assets/libs/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/Application/iframe/assets/libs/layuiadmin/style/mylay.css" media="all">
    <style type="text/css">
        html {background: #fff;padding-top: 20px;}
    </style>
</head>
<body>
<div class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label"><span>*</span> 优惠卷说明</label>
        <div class="layui-input-inline">
            <input type="text" name="explain" lay-verify="required" placeholder="请输入优惠卷说明" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>

    
  
    <div class="layui-form-item">
        <label class="layui-form-label"><span>*</span>优惠卷价格</label>
        <div class="layui-input-inline">
            <input type="text" name="money" lay-verify="required"  placeholder="优惠卷价格" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label"><span>*</span>优惠卷满足价格</label>
        <div class="layui-input-inline">
            <input type="text" name="amout" lay-verify="required"  placeholder="优惠卷满足价格" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">限制说明</label>
        <div class="layui-input-inline">
            <input type="text" name="restrictions"  placeholder="限制说明" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label"><span>*</span> 优惠卷开始时间</label>
        <div class="layui-input-inline">
            <input type="text" name="start_time" lay-verify="required" class="layui-input" id="test1" placeholder="yyyy-MM-dd HH-MM-SS">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label"><span>*</span> 优惠卷结束时间</label>
        <div class="layui-input-inline">
            <input type="text" name="end_time"  lay-verify="required" class="layui-input" id="test3" placeholder="yyyy-MM-dd HH-MM-SS">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    
  
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-submit" id="LAY-submit" value="确认">
    </div>
</div>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="/Application/iframe/assets/libs/layuiadmin/layui/layui.js"></script>

<script>

    layui.use('laydate', function(){
      var laydate = layui.laydate;
      //常规用法
      laydate.render({
        elem: '#test1'
        ,trigger: 'click'
        ,type:"datetime"
        ,format :"yyyy-MM-dd HH:mm:ss"
      });
      laydate.render({
        elem: '#test3'
        ,trigger: 'click'
        ,type:"datetime"
        ,format :"yyyy-MM-dd HH:mm:ss"
      });
    });


    layui.config({
        base: '/Application/iframe/assets/libs/layuiadmin/'
    }).extend({
        index: 'lib/index'
    }).use(['index', 'form', 'upload'], function(){
        var $ = layui.$
            ,upload = layui.upload
            ,form = layui.form;
        //上传
    
        //多图片上传
        //多图片上传
          upload.render({
            elem: '#test2'
            ,url: '{:U('upload/uploadFile')}' //改成您自己的上传接口
            ,multiple: true
            ,before: function(obj){
              //预读本地文件示例，不支持ie8
              obj.preview(function(index, file, result){
                $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
              });
            }
            ,done: function(res){
              //上传完毕
                console.log(res);
                if(res.code ==  '1001'){
                    $("#thumb").val($("#thumb").val()+res.src+',')
                }
                
            }
          });

    })
    $("#LAY-submit").click(function(){
        var arr = new Array();
   
         $("input:checkbox[name='spec_id[]']:checked").each(function(i){
            arr[i] = $(this).val();
        });
        var arrData = arr.join(",");
        $("#spec_id").val(arrData);
        console.log(arrData);
  
        
    })
    
   
      //data.field.like = arr.join(",");//将数组合并成字符串
</script>
</body>
</html>